<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <h1>这是主应用</h1>
    {{project}}
    <h2 @click="sendMes">{{project.name}}</h2>
    <h2 @click="sendMes1">{{project.age}}</h2>
    <HelloWorld msg="Welcome to Your Vue.js App"/>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import actions from '../action'

export default {
  name: 'Home',
  components: {
    HelloWorld
  },
  data () {
    return {
      mes: 'wangwu'
    }
  },
  methods: {
    sendMes () {
      actions.setGlobalState({ name: 'zs' })// 通过setGlobalState改变全局状态
    },
    sendMes1 () {
      actions.setGlobalState({ age: 6 })// 通过setGlobalState改变全局状态
    }
  },
  computed: {
    project: function () {
      return this.$store.state.msg
    }
  }
}
</script>
